import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

/**类似于Android中的ScrollView
 * SingleChildScrollView({
    this.scrollDirection = Axis.vertical, //滚动方向，默认是垂直方向
    /// this.reverse = false,  true时，那么滑动方向就是从右往左
    this.padding,
    bool primary,
    this.physics,
    this.controller,
    this.child,
    })
 */

///通常SingleChildScrollView只应在期望的内容不会超过屏幕太多时使用
///因为SingleChildScrollView不支持基于Sliver的延迟实例化模型
///SingleChildScrollView将会非常昂贵（性能差）
class SingleScrollView extends StatelessWidget {
  SingleScrollView({Key ?key, @required this.text}) : super(key: key);

  final String ?text;

  @override
  Widget build(BuildContext context) {
    String str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    return Scaffold(
      appBar: AppBar(
        title: Text(text??''),
      ),
      body: Container(
        alignment: Alignment.center,
        child: Scrollbar(
          // 显示进度条
          child: SingleChildScrollView(
              padding: EdgeInsets.all(20),
              child: Column(
                //动态创建一个List<Widget>
                children: str
                    .split("")
                    .map((e) => Text(
                          e,
                          textScaleFactor: 3.0,
                        ))
                    .toList(),
              )),
        ),
      ),
    );
  }
}
